/***        This .do file generates the reduced-form regression results reported in        ***/
/*** "Self-Control and Demand for Preventive Health: Evidence from Hypertension in India". ***/

clear
set more off

use "....../BHMR_RESTAT_reduced_form.dta", clear

/*  Listing/Generating Explanatory Variables and Baseline Health Measures  */

local treatment_var "discnt fixcc_std flexcc_std fixcc_discnt flexcc_discnt"
local characteristics "hh_size gender age literate hh_income seagri bp_sys bp_dia weight hbp_freq_check tehp"

tabulate vill_id, gen(village)
local village_fe "village2 village3 village4" 

gen trust_ehp = .
replace trust_ehp = 1 if tehp == 1
replace trust_ehp = 1 if tehp == 2
replace trust_ehp = 1 if tehp == 3
replace trust_ehp = 0 if tehp == 4
replace trust_ehp = 0 if tehp == 5

gen hyper_bl = .
replace hyper_bl = 0 if bp_sys < 140 & bp_dia < 90
replace hyper_bl = 1 if (bp_sys >= 140 & bp_sys != .) | (bp_dia >= 90 & bp_dia != .)

gen prehyper_bl = .
replace prehyper_bl = 0 if bp_sys < 120 & bp_dia < 80
replace prehyper_bl = 1 if (bp_sys >= 120 & bp_sys < 140) | (bp_dia >= 80 & bp_dia < 90)
replace prehyper_bl = 1 if hyper_bl == 1

gen obesity_bl = .
replace obesity_bl = 0 if bmi < 30
replace obesity_bl = 1 if bmi >= 30 & bmi != .

gen overweight_bl = .
replace overweight_bl = 0 if bmi < 25
replace overweight_bl = 1 if bmi >= 25 & bmi != .

/*  Listing/Generating Outcome Variables and Endline Health Measures  */

gen visitfrac = visittotal/3

gen hyper_el = .
replace hyper_el = 0 if bp_sys_el < 140 & bp_dia_el < 90
replace hyper_el = 1 if (bp_sys_el >= 140 & bp_sys_el != .) | (bp_dia_el >= 90 & bp_dia_el != .)

gen prehyper_el = .
replace prehyper_el = 0 if bp_sys_el < 120 & bp_dia_el < 80
replace prehyper_el = 1 if (bp_sys_el >= 120 & bp_sys_el < 140) | (bp_dia_el >= 80 & bp_dia_el < 90)
replace prehyper_el = 1 if hyper_el == 1

replace height = height/100
gen bmi_el = weight_el/(height)^2

replace bmi_el = . if bmi_el > 100

gen obesity_el = .
replace obesity_el = 0 if bmi_el < 30
replace obesity_el = 1 if bmi_el >= 30 & bmi_el != .

gen overweight_el = .
replace overweight_el = 0 if bmi_el < 25
replace overweight_el = 1 if bmi_el >= 25 & bmi_el != .

local outcomes "takeup visitfrac anyvisit bp_sys_el bp_dia_el weight_el hyper_bl hyper_el obesity_bl obesity_el overweight_bl overweight_el"

/* Generating Sample Indicators */
/* Panel A contains the following outcomes: Contract Take-up and Clinic Visits */
/* Panel B contains the following outcomes: Endline weight and BP */
/* Target or "Ideal" Sample include individuals that both believe it is possible
   to be health with hypertension and trusts the service provider. */

gen PanelA_Sample = 0 
replace PanelA_Sample = 1 if takeup != . & anyvisit != . & visittotal != .

gen PanelB_Sample = 0
replace PanelB_Sample = 1 if weight_el != . & bp_sys_el != . & bp_dia_el != . 

gen target_sample = 0
replace target_sample = 1 if hbp_freq_check == 1 & trust_ehp == 1

gen Target_PanelA_Sample = 0
replace Target_PanelA_Sample = 1 if hbp_freq_check == 1 & trust_ehp == 1 & takeup != . & anyvisit != . & visittotal != . 

gen Target_PanelB_Sample = 0
replace Target_PanelB_Sample = 1 if hbp_freq_check == 1 & trust_ehp == 1 & weight_el != . & bp_sys_el != . & bp_dia_el != . 

********************************************************************************
************************  Table 1: Summary Stats  ******************************
********************************************************************************

sutex2 hh_size gender age hhh_literate hh_income hhh_seagri
sutex2 bp_sys bp_dia prehyper_bl hyper_bl 
sutex2 weight overweight_bl obesity_bl
sutex2 takeup visitfrac anyvisit if PanelA_Sample
sutex2 bp_sys_el bp_dia_el weight_el prehyper_el hyper_el overweight_el obesity_el if PanelB_Sample

********************************************************************************
********Table 2: Main study outcomes by treatment group: Full sample ***********
********************************************************************************

reg takeup `treatment_var' `village_fe' if PanelA_Sample == 1, vce(robust)	
reg anyvisit `treatment_var' `village_fe' if PanelA_Sample == 1, vce(robust)
reg visitfrac `treatment_var' `village_fe' if PanelA_Sample == 1, vce(robust)

reg bp_sys_el `treatment_var' `village_fe' bp_sys bp_dia weight if PanelB_Sample == 1, vce(robust)
reg bp_dia_el `treatment_var' `village_fe' bp_sys bp_dia weight if PanelB_Sample == 1, vce(robust)
reg weight_el `treatment_var' `village_fe' bp_sys bp_dia weight if PanelB_Sample == 1, vce(robust)

********************************************************************************
*******Table 3: Main study outcomes by treatment group: "Ideal" sample *********
********************************************************************************	

reg takeup `treatment_var' `village_fe' if Target_PanelA_Sample == 1, vce(robust)
reg anyvisit `treatment_var' `village_fe' if Target_PanelA_Sample == 1, vce(robust)
reg visitfrac `treatment_var' `village_fe' if Target_PanelA_Sample == 1, vce(robust)
	
reg bp_sys_el `treatment_var' `village_fe' bp_sys bp_dia weight if Target_PanelB_Sample == 1, vce(robust)
reg bp_dia_el `treatment_var' `village_fe' bp_sys bp_dia weight if Target_PanelB_Sample == 1, vce(robust)
reg weight_el `treatment_var' `village_fe' bp_sys bp_dia weight if Target_PanelB_Sample == 1, vce(robust)	
	
********************************************************************************
****************Table A.1: Balance check across treatment groups****************
********************************************************************************

foreach characteristic of local characteristics{
	
	reg `characteristic' discnt fixcc_std flexcc_std fixcc_discnt flexcc_discnt `village_fe', vce(robust)
	test discnt fixcc_std flexcc_std fixcc_discnt flexcc_discnt
	
	}

********************************************************************************
****************    Table A.2: Endline Health Outcomes:       ******************
****************   Incidence of Hypertension and Obesity      ******************
********************************************************************************
	
reg prehyper_el `treatment_var' `village_fe' bp_sys bp_dia weight if PanelB_Sample == 1, vce(robust)
reg hyper_el `treatment_var' `village_fe' bp_sys bp_dia weight if PanelB_Sample == 1, vce(robust)
reg overweight_el `treatment_var' `village_fe' bp_sys bp_dia weight if PanelB_Sample == 1, vce(robust)
reg obesity_el `treatment_var' `village_fe' bp_sys bp_dia weight if PanelB_Sample == 1, vce(robust)
	
reg prehyper_el `treatment_var' `village_fe' bp_sys bp_dia weight if Target_PanelB_Sample == 1, vce(robust)
reg hyper_el `treatment_var' `village_fe' bp_sys bp_dia weight if Target_PanelB_Sample == 1, vce(robust)
reg overweight_el `treatment_var' `village_fe' bp_sys bp_dia weight if Target_PanelB_Sample == 1, vce(robust)
reg obesity_el `treatment_var' `village_fe' bp_sys bp_dia weight if Target_PanelB_Sample == 1, vce(robust)


********************************************************************************
************Table A.3: Endline Health Outcomes by Treatment Group:**************
**************************   Without Baseline Controls    **********************
********************************************************************************

reg bp_sys_el `treatment_var' `village_fe' if PanelB_Sample == 1, vce(robust)
reg bp_dia_el `treatment_var' `village_fe' if PanelB_Sample == 1, vce(robust)
reg weight_el `treatment_var' `village_fe' if PanelB_Sample == 1, vce(robust)

reg bp_sys_el `treatment_var' `village_fe' if Target_PanelB_Sample == 1, vce(robust)
reg bp_dia_el `treatment_var' `village_fe' if Target_PanelB_Sample == 1, vce(robust)
reg weight_el `treatment_var' `village_fe' if Target_PanelB_Sample == 1, vce(robust)	



	
